package com.atguigu.gmall.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.product.client.ProductFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private ProductFeignClient productFeignClient;
    @GetMapping({"/", "/index.html"})
    public String index(Model model) {
        //todo 获取渲染首页-商品数据 将来为了提高首页数据渲染,必然调用多个服务feign接口 采用异步服务编排进行优化
        //todo 获取渲染首页-广告数据
        //获取渲染首页-分类数据
        List<JSONObject> list = productFeignClient.getBaseCategoryList();
        model.addAttribute("list", list);
        return "/index/index";
    }

}
